package com.woniu.his.bms.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniu.his.bms.client.BmsFeeQueryClient;
import com.woniu.his.bms.client.result.BmsDoctorPatientFeeResult;
import com.woniu.his.bms.service.BillsRecordService;
import com.woniu.his.bms.service.dto.BmsDoctorPatientFeeDto;
import com.woniu.his.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version: java version 1.8
 * @Author: Mr tao
 * @description:
 * @date: 2022-12-01 11:29
 */
@Slf4j
@RestController
@RequestMapping("bms")
public class BmsFeeQueryApiImpl implements BmsFeeQueryClient {




    @Resource
    private BillsRecordService billsRecordService;

    /**
     * 费用查询
     * @param CaseHistoryId
     * @return
     */
    @Override
    public Result<List<BmsDoctorPatientFeeResult>> listFeeByCaseHistoryId(Long CaseHistoryId) {
      log.info("通过病例id费用查询:{}",CaseHistoryId);

      List<BmsDoctorPatientFeeDto> dto=  billsRecordService.listFeeByCaseHistoryId(CaseHistoryId);
      if(dto.isEmpty()) return null;
        return Result.getInstanceList(BmsDoctorPatientFeeResult.class).setData(BeanUtil.copyToList(dto,BmsDoctorPatientFeeResult.class));
    }
}
